package com.wwl.cms.utils.designModeTest.observer;

import lombok.Data;

/**
 * @author wwl
 * @version 1.0
 * @date 2021/9/13 19:25
 * @description:
 */
@Data
public class WeatherData {
    private float temperature;
    private float pressure;
    private float humidity;
    private CurrentConditions currentConditions;

    //加入新的第三方
    public WeatherData(CurrentConditions currentConditions) {
        this.currentConditions = currentConditions;
    }

    public void dataChange(){
        //调用 接入方的update
        currentConditions.update(getTemperature(),getPressure(),getHumidity());
    }

    //当有数据更新时，就调用setData
    public void setData(float temperature,float pressure,float humidity){
        this.temperature = temperature;
        this.pressure = pressure;
        this.humidity = humidity;
        //调用dataChange,将最新的信息，接入currentConditions
        dataChange();
    }

}
